package com.sbeam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sbeam.pojo.Games;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface GamesMapper extends BaseMapper<Games> {
    List<Games> getGamesList();

    List<Games> findGamesByName(Map map);

    @Select("select id,images from games where parent_id=#{parentId} order by price")
    List<Games> findGamesByParentId(Integer parentId);

    List<Games> getGamesListM();

    int updateGamesStatus(Games games);

    List<Games> getGamesByFactoryId(Integer factoryId);

    @Select("select * from games where id=#{id}")
    Games getGamesById(Integer id);

    @Update("update games set name=#{name},price=#{price},discount=#{discount},updated=#{updated} where id=#{id}")
    int updateGamesById(Games games);

    @Delete("delete from games where id = #{id}")
    int deleteGamesById(Integer id);

    int addGames(Games games);

    @Select("select count(1) from games where name like #{key}")
    int findTotal(String key);
}
